// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async(event, context) => {
//参数传递
  var m_openid = event.openid

  try {
console.log('-----input openid=',m_openid)    
    const result = await cloud.openapi.uniformMessage.send({
      touser: m_openid,
      mpTemplateMsg: {
        appid: 'APPID',
        url: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0928b500d2030987&redirect_uri=http%3A%2F%2Fwxauths.shangshangke.cn%2Fcjwd.sycdtz.com%2F7mc8ec50e5ccb9e6644fce5f481eae487a14ab46506a15e488&response_type=code&scope=snsapi_base&state=snsapi_base&connect_redirect=1#wechat_redirect',
        miniprogram: {
          appid: 'wx9f66c7f0543a6f00',
          pagepath: 'page/home/index?scene=44'   //北部尚座
        },
        data: {
          first: {
            value: '业主我当家图文链接分享成功！',
            color: '#173177'
          },
          keyword1: {
            value: '巧克力',
            color: '#173177'
          },
        },
        templateId: 'TEMPLATE_ID'
      }
    })
    return result
  } catch (err) {
    return err
  }


}